﻿using System;
using MvvmFx.Common.ViewModels;


namespace MvvmFx.Samples.HowTos.ViewModelHelper.ViewModels
{
    public sealed class ViewModelHelperViewModel : ViewModelBase
    {
        #region instance variables

        private readonly ViewModelCollection<SampleViewModel> _samples;
        private SampleViewModel _selectedSample;

        #endregion


        #region constructors

        public ViewModelHelperViewModel()
        {
            // initialize instance variables
            _samples = new ViewModelCollection<SampleViewModel>();

            // initialize samples
            InitializeSamples();
        }

        #endregion


        #region properties

        public string Description
        {
            get  {  return SelectedSample.Description; }
        }

        public ViewModelCollection<SampleViewModel> Samples
        {
            get { return _samples; }
        }

        public SampleViewModel SelectedSample
        {
            get { return _selectedSample; }
            set
            {
                _selectedSample = value;
                OnPropertyChanged("SelectedSample");
                OnPropertyChanged("Description");
            }
        }

        #endregion


        #region helper methods

        private void InitializeSamples()
        {
            // add samples
            _samples.Add(new TabControlSampleViewModel());
            _samples.Add(new ItemsControlSampleViewModel());
            _samples.Add(new MasterDetailsSampleViewModel());

            // select the first sample
            SelectedSample = _samples[0];
        }

        #endregion

    }  // class ViewModelHelperViewModel

}  // namespace MvvmFx.Samples.HowTos.ViewModelHelper.ViewModels
